package cn.edu.scau.cmi.foodRecognite;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.text.Position.Bias;

public class RGB {
	public static void RGBAnalysis(String path) throws IOException{
		int[] rgb=new int [3];
				if(!(path==null)&&!path.trim().isEmpty()){
					File file=new File(path);
					BufferedImage bufIma=ImageIO.read(file);
					int width=bufIma.getWidth();
					int height=bufIma.getHeight();
					int minx=bufIma.getMinX();
					int miny=bufIma.getMinY();
					for(int i=minx;i<width;i++){
						for(int j=miny;j<height;j++){
							int pixel=bufIma.getRGB(i, j);
							rgb[0] = (pixel & 0xff0000) >> 16;  //R
							rgb[1] = (pixel & 0xff00) >> 8;  //G
							rgb[2] = (pixel & 0xff);  //B
						}
					}
				}
	}
}
